﻿using System;
using SharpSqlAnalyzer.nodes;

namespace SharpSqlAnalyzer
{
	// Token: 0x02000044 RID: 68
	public class TCustomParser
	{
		// Token: 0x17000001 RID: 1
		// (get) Token: 0x06000035 RID: 53 RVA: 0x00004042 File Offset: 0x00002242
		public virtual TNodeFactory NodeFactory
		{
			get
			{
				return this.nf;
			}
		}

		// Token: 0x06000036 RID: 54 RVA: 0x0000404C File Offset: 0x0000224C
		internal TCustomParser()
		{
			this.curtokenpos = 0;
			this.yylval = new TDatabaseYYSType();
			this.yyv = new TDatabaseYYSType[this.yymaxdepth + 1];
			this.yyval = null;
			this.sqlcmds = new TSqlCmds();
			this.nf = new TNodeFactory();
		}

		// Token: 0x06000037 RID: 55 RVA: 0x00004137 File Offset: 0x00002337
		internal virtual TParseTreeNodeList yacclcons(object obj, TParseTreeNodeList parseTreeNodeList, bool IsParse)
		{
			return null;
		}

		// Token: 0x06000038 RID: 56 RVA: 0x0000413A File Offset: 0x0000233A
		internal virtual TParseTreeNodeList yaccmakeList1(object x1, bool IsParse)
		{
			return null;
		}

		// Token: 0x06000039 RID: 57 RVA: 0x0000413D File Offset: 0x0000233D
		internal virtual TParseTreeNodeList yaccmakeList2(object x1, object x2, bool IsParse)
		{
			return null;
		}

		// Token: 0x0600003A RID: 58 RVA: 0x00004140 File Offset: 0x00002340
		internal virtual TParseTreeNodeList yaccnconc(TParseTreeNodeList l1, TParseTreeNodeList l2)
		{
			return null;
		}

		// Token: 0x0600003B RID: 59 RVA: 0x00004143 File Offset: 0x00002343
		internal virtual TParseTreeNodeList yacclappend(TParseTreeNodeList parseTreeNodeList, object obj, bool IsParse)
		{
			return null;
		}

		// Token: 0x0600003C RID: 60 RVA: 0x00004148 File Offset: 0x00002348
		internal virtual int yylexwrap(bool isignore)
		{
			int result = 0;
			if (this.sourcetokenlist == null)
			{
				return result;
			}
			TSourceToken tsourceToken = this.getasourcetoken(isignore);
			if (tsourceToken == null)
			{
				return result;
			}
			if (tsourceToken.tokencode == 0)
			{
				return result;
			}
			this.yylval.yyTSourceToken = tsourceToken;
			if (this.yylval.yyTSourceToken.tokencode == 267 && this.dbvendor == EDbVendor.dbvmysql)
			{
				this.yylval.yyTSourceToken.tokencode = 264;
			}
			if (this.dbvendor == EDbVendor.dbvoracle)
			{
				this.yylval.yyTSourceToken.tag = 0;
			}
			return this.yylval.yyTSourceToken.tokencode;
		}

		// Token: 0x0600003D RID: 61 RVA: 0x000041E5 File Offset: 0x000023E5
		internal virtual TSourceToken read_to_next_parentheses(bool isIncluding)
		{
			return this.read_to_next_parentheses(isIncluding, new TDummy());
		}

		// Token: 0x0600003E RID: 62 RVA: 0x000041F4 File Offset: 0x000023F4
		internal virtual TSourceToken read_to_next_parentheses(bool isIncluding, TParseTreeNode ownerNode)
		{
			int num = 0;
			TSourceToken tsourceToken = null;
			TSourceToken tsourceToken2 = null;
			for (;;)
			{
				int num2 = this.yylexwrap(false);
				if (num2 < 0)
				{
					num2 = 0;
				}
				if (num2 == 0)
				{
					break;
				}
				if (this.yylval.yyTSourceToken.tokentype == ETokenType.ttleftparenthesis)
				{
					num++;
				}
				if (this.yylval.yyTSourceToken.tokentype == ETokenType.ttrightparenthesis)
				{
					num--;
				}
				if (tsourceToken2 == null)
				{
					ownerNode.startToken = this.yylval.yyTSourceToken;
				}
				if (num < 0)
				{
					goto Block_6;
				}
				tsourceToken = this.yylval.yyTSourceToken;
				if (this.yylval.yyTSourceToken.tokentype == ETokenType.ttsemicolon)
				{
					goto Block_8;
				}
				tsourceToken2 = this.yylval.yyTSourceToken;
			}
			return tsourceToken;
			Block_6:
			if (isIncluding)
			{
				this.stmtendpos = this.curtokenpos;
				tsourceToken = this.yylval.yyTSourceToken;
				ownerNode.endToken = tsourceToken;
				return tsourceToken;
			}
			this.curtokenpos--;
			this.stmtendpos = this.curtokenpos;
			tsourceToken = tsourceToken2;
			ownerNode.endToken = tsourceToken;
			return tsourceToken;
			Block_8:
			ownerNode.endToken = tsourceToken;
			return tsourceToken;
		}

		// Token: 0x0600003F RID: 63 RVA: 0x000042E8 File Offset: 0x000024E8
		internal virtual TSourceToken read_before_this_token(int pTokenCode)
		{
			TSourceToken result = null;
			for (;;)
			{
				int num = this.yylexwrap(false);
				if (num < 0)
				{
					num = 0;
				}
				if (num == 0)
				{
					break;
				}
				if (this.yylval.yyTSourceToken.tokencode == pTokenCode)
				{
					goto Block_3;
				}
				result = this.yylval.yyTSourceToken;
				if (this.yylval.yyTSourceToken.tokentype == ETokenType.ttsemicolon)
				{
					return result;
				}
			}
			return result;
			Block_3:
			this.curtokenpos--;
			return result;
		}

		// Token: 0x06000040 RID: 64 RVA: 0x00004350 File Offset: 0x00002550
		internal virtual TSourceToken read_to_semicolon()
		{
			return this.read_to_semicolon(new TDummy());
		}

		// Token: 0x06000041 RID: 65 RVA: 0x00004360 File Offset: 0x00002560
		internal virtual TSourceToken read_to_semicolon(TParseTreeNode ownerNode)
		{
			TSourceToken tsourceToken = null;
			for (;;)
			{
				int num = this.yylexwrap(false);
				if (num < 0)
				{
					num = 0;
				}
				if (num == 0)
				{
					break;
				}
				if (tsourceToken == null && ownerNode.startToken == null)
				{
					ownerNode.startToken = this.yylval.yyTSourceToken;
				}
				tsourceToken = this.yylval.yyTSourceToken;
				if (this.yylval.yyTSourceToken.tokentype == ETokenType.ttsemicolon)
				{
					goto Block_5;
				}
			}
			return tsourceToken;
			Block_5:
			if (tsourceToken.tokentype == ETokenType.ttsemicolon)
			{
				ownerNode.setEndToken(tsourceToken.PrevTokenInChain);
			}
			else
			{
				ownerNode.setEndToken(tsourceToken);
			}
			return tsourceToken;
		}

		// Token: 0x06000042 RID: 66 RVA: 0x000043E0 File Offset: 0x000025E0
		internal virtual TSourceToken getasourcetoken(bool isignore)
		{
			TSourceToken tsourceToken = null;
			if (this.sourcetokenlist == null)
			{
				return null;
			}
			if (this.curtokenpos > this.sourcetokenlist.size() - 1)
			{
				return null;
			}
			int i;
			for (i = this.curtokenpos; i < this.sourcetokenlist.size(); i++)
			{
				tsourceToken = this.sourcetokenlist.get(i);
				if ((tsourceToken.tokencode != 259 || !isignore) && (tsourceToken.tokencode != 260 || !isignore) && (tsourceToken.tokencode != 258 || !isignore) && (tsourceToken.tokencode != 257 || !isignore) && tsourceToken.tokenstatus != ETokenStatus.tsignorebyyacc && tsourceToken.tokenstatus != ETokenStatus.tsdeleted)
				{
					break;
				}
			}
			if (i == this.sourcetokenlist.size())
			{
				return null;
			}
			this.curtokenpos += i - this.curtokenpos + 1;
			return tsourceToken;
		}

		// Token: 0x06000043 RID: 67 RVA: 0x000044B8 File Offset: 0x000026B8
		internal virtual int dobefore_yyparse()
		{
			int result = 10000;
			for (int i = 0; i < this.sourcetokenlist.size(); i++)
			{
				if (this.sourcetokenlist.get(i).tokentype != ETokenType.ttwhitespace && this.sourcetokenlist.get(i).tokentype != ETokenType.ttreturn && this.sourcetokenlist.get(i).tokencode != 258 && this.sourcetokenlist.get(i).tokencode != 257)
				{
					result = 0;
					break;
				}
			}
			return result;
		}

		// Token: 0x06000044 RID: 68 RVA: 0x0000453E File Offset: 0x0000273E
		internal virtual void onparseerrorhandle(EErrorType errortype, string pmsg, string token, long xposition, long yposition, int errorno)
		{
			if (this.sql != null)
			{
				this.sql.parseerrormessagehandle(new TSyntaxError(token, xposition, yposition, pmsg, errortype, errorno));
				return;
			}
			Console.WriteLine(pmsg);
		}

		// Token: 0x06000045 RID: 69 RVA: 0x00004569 File Offset: 0x00002769
		internal virtual bool yyact(int state, int sym, int[] act)
		{
			return false;
		}

		// Token: 0x06000046 RID: 70 RVA: 0x0000456C File Offset: 0x0000276C
		internal virtual bool yygoto(int state, int sym, int[] nstate)
		{
			return false;
		}

		// Token: 0x06000047 RID: 71 RVA: 0x00004570 File Offset: 0x00002770
		internal virtual void geterrormsg(int state, int sym, int errorno)
		{
			if (this.sql != null)
			{
				string hint;
				if (sym == 0)
				{
					hint = "end of input";
				}
				else
				{
					hint = "syntax error, state:" + state.ToString();
				}
				this.sql.parseerrormessagehandle(new TSyntaxError(this.currentsourcetoken.astext, this.currentsourcetoken.lineNo, this.currentsourcetoken.columnNo, hint, EErrorType.spfatalerror, errorno));
				return;
			}
			Console.WriteLine("syntax error 10033,state:" + state.ToString());
		}

		// Token: 0x06000048 RID: 72 RVA: 0x000045EE File Offset: 0x000027EE
		internal virtual void yyaction(int yyruleno)
		{
		}

		// Token: 0x06000049 RID: 73 RVA: 0x000045F0 File Offset: 0x000027F0
		public virtual int yyparse()
		{
			return -1;
		}

		// Token: 0x04000D8E RID: 3470
		internal EDbVendor dbvendor;

		// Token: 0x04000D8F RID: 3471
		internal TDatabaseYYSType yylval;

		// Token: 0x04000D90 RID: 3472
		internal TDatabaseYYSType[] yyv;

		// Token: 0x04000D91 RID: 3473
		internal TDatabaseYYSType yyval;

		// Token: 0x04000D92 RID: 3474
		internal int yysp;

		// Token: 0x04000D93 RID: 3475
		internal bool isbeginofbatch;

		// Token: 0x04000D94 RID: 3476
		internal TSourceTokenList tmp_sourcetokenlist;

		// Token: 0x04000D95 RID: 3477
		internal int tmp_curtokenpos;

		// Token: 0x04000D96 RID: 3478
		public TSourceTokenList sourcetokenlist;

		// Token: 0x04000D97 RID: 3479
		public TNodeFactory nf;

		// Token: 0x04000D98 RID: 3480
		public TParseTreeNode rootNode;

		// Token: 0x04000D99 RID: 3481
		internal readonly int yymaxdepth = 1048;

		// Token: 0x04000D9A RID: 3482
		internal readonly int _error = 256;

		// Token: 0x04000D9B RID: 3483
		internal readonly int yyfnone;

		// Token: 0x04000D9C RID: 3484
		internal readonly int yyfaccept = 1;

		// Token: 0x04000D9D RID: 3485
		internal readonly int yyfabort = 2;

		// Token: 0x04000D9E RID: 3486
		internal readonly int yyferror = 3;

		// Token: 0x04000D9F RID: 3487
		internal readonly int aopAbort;

		// Token: 0x04000DA0 RID: 3488
		internal readonly int aopContinue = 1;

		// Token: 0x04000DA1 RID: 3489
		internal readonly int tsOriginal;

		// Token: 0x04000DA2 RID: 3490
		internal readonly int tsDeleted = 1;

		// Token: 0x04000DA3 RID: 3491
		internal readonly int tsIgnoreByYacc = 2;

		// Token: 0x04000DA4 RID: 3492
		internal readonly int tsMarkDeletedInPPDoWhiteSpace = 3;

		// Token: 0x04000DA5 RID: 3493
		internal readonly int tsAddedInPP = 4;

		// Token: 0x04000DA6 RID: 3494
		internal readonly int tsDeletedInPP = 5;

		// Token: 0x04000DA7 RID: 3495
		internal readonly int tsAlreadlyAddedToList = 6;

		// Token: 0x04000DA8 RID: 3496
		internal readonly int tsSynataxError = 7;

		// Token: 0x04000DA9 RID: 3497
		internal readonly int tsSynataxErrorProcessed = 8;

		// Token: 0x04000DAA RID: 3498
		internal readonly int tsAddbyHand = 9;

		// Token: 0x04000DAB RID: 3499
		internal readonly int tsAddedInTokensInScript = 10;

		// Token: 0x04000DAC RID: 3500
		internal readonly int tsIgnoredByGetRawStatement = 11;

		// Token: 0x04000DAD RID: 3501
		internal readonly int tsDummyStatus = 12;

		// Token: 0x04000DAE RID: 3502
		internal TSqlCmds sqlcmds;

		// Token: 0x04000DAF RID: 3503
		internal TCustomLexer lexer;

		// Token: 0x04000DB0 RID: 3504
		internal TParseTreeNode tmpnode;

		// Token: 0x04000DB1 RID: 3505
		internal TParseTreeNode tmpnode1;

		// Token: 0x04000DB2 RID: 3506
		internal TParseTreeNode tmpnode2;

		// Token: 0x04000DB3 RID: 3507
		internal TParseTreeNode tmpnode3;

		// Token: 0x04000DB4 RID: 3508
		internal TParseTreeNode tmpnode4;

		// Token: 0x04000DB5 RID: 3509
		internal object tmpObject;

		// Token: 0x04000DB6 RID: 3510
		internal int yyflag;

		// Token: 0x04000DB7 RID: 3511
		internal int nextstmtstartpos;

		// Token: 0x04000DB8 RID: 3512
		internal int curtokenpos;

		// Token: 0x04000DB9 RID: 3513
		internal int stmtendpos;

		// Token: 0x04000DBA RID: 3514
		internal TSourceToken acceptedtoken;

		// Token: 0x04000DBB RID: 3515
		internal TSourceToken currentsourcetoken;

		// Token: 0x04000DBC RID: 3516
		internal TSourceToken recovertoken;

		// Token: 0x04000DBD RID: 3517
		internal TSourceToken errorstmtstarttoken;

		// Token: 0x04000DBE RID: 3518
		internal int currentyystate;

		// Token: 0x04000DBF RID: 3519
		internal int currentyysp;

		// Token: 0x04000DC0 RID: 3520
		internal int currentyyn;

		// Token: 0x04000DC1 RID: 3521
		internal int[] retvalue = new int[1];

		// Token: 0x04000DC2 RID: 3522
		public TCustomSqlStatement sql;
	}
}
